package com.bdqn.controller;

import com.bdqn.pojo.Demo;
import com.bdqn.service.DemoService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * DemoController
 *
 * @author LILIBO
 * @since 2022-01-12
 */
@RestController // 所有方法将以原内容返回（而不是视图名称）
@RequestMapping("/demo")
public class DemoController {

    @Resource
    private Demo demo;

    @Resource
    private DemoService demoService;

    @RequestMapping("/hello/{name}")
    public String hello(@PathVariable("name") String name) {
        return demoService.sayHello(name);
    }

    // @Value("${com.bdqn.name}")
    // private String name;
    // @Value("${com.bdqn.email}")
    // private String email;

    @RequestMapping("/hi")
    public String hi() {
        System.out.println("邮箱：" + demo.getEmail());
        return demoService.sayHello(demo.getName());
    }
}
